const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
// 云函数入口
exports.main = async (event, context) => {
  let { listName, form } = event
  try {
    return await db.collection(listName).add({
      // data 字段表示需新增的 JSON 数据
      data: form
    })
  } catch(e) {
    console.error(e)
  }
}